package com.ttt.adbgui;

import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;

@SpringBootApplication
public class AdbguiApplication {

    public static void main(String[] args) {
        /*
         * // 不用注册窗口组件的相关信息
         * // 虚拟机参数：-Djava.awt.headless=false
         * ConfigurableApplicationContext run = SpringApplication.run(TttApplication.class, args);
         * Object startMain = run.getBeanFactory().getBean("startMain");
         * Method start = ReflectionUtils.findMethod(startMain.getClass(), "start");
         * ReflectionUtils.invokeMethod(start,startMain);
         * */

        // 注册jxbrowser-swing许可
        System.setProperty("jxbrowser.license.key", "1BNDHFSC1G3706U7I8G8GUQZ2GT3MNJ43F9JR744R6ZOUZ2SDBGE39WJ1KQ0JU92X3RVR0");

        SpringApplicationBuilder run = new SpringApplicationBuilder(AdbguiApplication.class);
        run.headless(false).web(WebApplicationType.NONE).run(args);

        // 获取springboot的bean
        Object startMain = run.context().getBeanFactory().getBean("startMain");
        // 利用反射执行自己的方法
        Method start = ReflectionUtils.findMethod(startMain.getClass(), "start");
        ReflectionUtils.invokeMethod(start,startMain);
    }

}
